use syn::{
    punctuated::Punctuated, token::Comma, Data, DataStruct, DeriveInput, Field, Fields,
    FieldsNamed, Ident,
};

pub(crate) fn ident(st: &DeriveInput) -> &Ident {
    &st.ident
}

pub(crate) fn fields(st: &DeriveInput) -> &Punctuated<Field, Comma> {
    if let Data::Struct(DataStruct {
        fields: Fields::Named(FieldsNamed { named, .. }, ..),
        ..
    }) = &st.data
    {
        return named;
    }
    unreachable!()
}

// pub(crate) fn field_attr(
//     fields: &Punctuated<Field, Comma>,
// ) -> Vec<(Option<proc_macro2::Ident>, Vec<Attribute>)> {
//     fields
//         .iter()
//         .map(|f| (f.ident.clone(), f.attrs.clone()))
//         .collect::<Vec<_>>()
// }

// pub(crate) fn field_parits(fields: &Punctuated<Field, Comma>) -> (Vec<Option<Ident>>, Vec<Type>) {
//     let iv = fields.iter().map(|f| f.ident.clone()).collect::<Vec<_>>();
//     let tv = fields.iter().map(|f| f.ty.clone()).collect::<Vec<_>>();
//     return (iv, tv);
// }

// pub(crate) fn get_field_parits(st: &DeriveInput) -> (Vec<Option<Ident>>, Vec<Type>) {
//     let f = fields(st);
//     field_parits(f)
// }
